﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}

<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>@*
<script src="~/lib/layuiadmin/layui/layui.js"></script>
<script src="~/lib/layuiadmin/config.js"></script>
<link href="~/lib/layuiadmin/layui/css/layui.css" rel="stylesheet" /> *@



<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Demo</title>
    <!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
    @* <link href="//unpkg.com/layui@2.9.18/dist/css/layui.css" rel="stylesheet"> *@
</head>
<body>

    <form class="layui-form">
        <div class="layui-form-item">
            <div class="layui-form-item" style="width:2500px">

                <div class="layui-form-item">
                    <label class="layui-form-label">客户类型</label>
                    <div class="layui-input-block">
                        <input type="radio" name="clientTypeName" value="个人" title="个人">
                        <input type="radio" name="clientTypeName" value="企业" title="企业">
                    </div>
                </div>

                <div class="layui-inline" style="width:2000px">


                    <label class="layui-form-label" style="width:100px">负责人手机号</label>
                    <div class="layui-input-inline layui-input-wrap">
                        <input type="text" id="responsiblePhone" class="layui-input">
                    </div>

                    <label class="layui-form-label" style="width:100px">负责人姓名</label>
                    <div class="layui-input-inline layui-input-wrap">
                        <input type="text" id="responsibleName" lay-verify="required" autocomplete="off" lay-reqtext="请输入用户名" lay-affix="clear" class="layui-input demo-phone">
                    </div>

                </div>

                <div class="layui-inline" style="width:2000px">
                    <label class="layui-form-label" style="width:100px"> 客户名称</label>
                    <div class="layui-input-inline layui-input-wrap">
                        <input type="text" id="clientName" class="layui-input">
                    </div>

                    <label class="layui-form-label" style="width:100px">身份证</label>
                    <div class="layui-input-inline layui-input-wrap">
                        <input type="text" id="clientCard" lay-verify="required" autocomplete="off" lay-reqtext="请输入用户名" lay-affix="clear" class="layui-input demo-phone">
                    </div>

                </div>
                <div class="layui-inline" style="width:2000px">
                    <label class="layui-form-label" style="width:100px"> 所在地</label>
                    <div class="layui-input-inline layui-input-wrap">
                        <input type="text" id="clientAddr" lay-verify="required" autocomplete="off" lay-reqtext="必须填写四个字以上地址" lay-affix="clear" class="layui-input demo-phone">
                    </div>
                    <div style="width:400px;height:300px;border:#ccc solid 1px;" id="dituContent"></div>

                </div>

                <div class="layui-inline" style="width:2000px">
                    <label class="layui-form-label" style="width:110px"> 所属行业</label>
                    <div class="layui-input-inline layui-input-wrap">
                        <input type="text" id="cVindustry" class="layui-input">
                    </div>

                    <label class="layui-form-label" style="width:100px">统一社会信用代码</label>
                    <div class="layui-input-inline layui-input-wrap">
                        <input type="text" id="cvCreditcode" lay-verify="required" autocomplete="off" lay-reqtext="请输入用户名" lay-affix="clear" class="layui-input demo-phone">
                    </div>

                </div>
                <div class="layui-inline" style="width:2000px">
                    <label class="layui-form-label" style="width:100px"> 助记码</label>
                    <div class="layui-input-inline layui-input-wrap">
                        <input type="text" id="cVmnemonic" class="layui-input">
                    </div>

                    <label class="layui-form-label" style="width:100px">客户的归集档案</label>
                    <div class="layui-input-inline layui-input-wrap">
                        <input type="text" id="clientarchives" lay-verify="required" autocomplete="off" lay-reqtext="请输入用户名" lay-affix="clear" class="layui-input demo-phone">
                    </div>

                </div>
                <div class="layui-inline" style="width:2000px">
                    <label class="layui-form-label" style="width:100px"> 客户阶段</label>
                    <div class="layui-input-inline layui-input-wrap">
                        <input type="text" id="clientstage" class="layui-input">
                    </div>

                    <label class="layui-form-label" style="width:100px">客户自定义标签</label>
                    <div class="layui-input-inline layui-input-wrap">
                        <input type="text" id="clientlabel" lay-verify="required" autocomplete="off" lay-reqtext="请输入用户名" lay-affix="clear" class="layui-input demo-phone">
                    </div>

                </div>
                <div class="layui-inline" style="width:2000px">
                    <label class="layui-form-label" style="width:100px"> 意向产品</label>
                    <div class="layui-input-inline layui-input-wrap">
                        <input type="text" id="clientproducts" class="layui-input">
                    </div>

                </div>
                <div class="layui-inline" style="width:2000px">
                    <label class="layui-form-label" style="width:100px"> 合作日期</label>
                    <div class="layui-input-inline layui-input-wrap">
                        <input type="date" id="clientcooperate" class="layui-input">
                    </div>

                </div>


                <div class="layui-inline" style="width:2000px">
                    <label class="layui-form-label" style="width:200px"> 所属单位：宏光养羊</label>

5
成员
0
游客
0
待定

                    <label class="layui-form-label" style="width:100px">使用状态</label>
                    <div class="layui-input-inline layui-input-wrap">
                        <div class="layui-input-inline">
                            <input type="radio" name="cVstatus" value="启用" title="启用">
                            <input type="radio" name="cVstatus" value="禁用" title="禁用">
                        </div>
                    </div>

                </div>

                <div class="layui-inline" style="width:2000px">
                    <label class="layui-form-label" style="width:110px"> 上级客户</label>
                    <div class="layui-input-inline">
                        <select name="city" id="superiorClient" lay-filter="aihao">
                            <option value="">请选择上级客户</option>
                            <option value="张三">张三</option>
                            <option value="李思">李思</option>
                            <option value="王五">王五</option>
                        </select>
                    </div>

                    <label class="layui-form-label" style="width:100px">客户级别</label>
                    <div class="layui-input-inline">
                        <select name="city" id="clientlevel" lay-filter="aihao">
                            <option value="1级">1级</option>
                            <option value="2级">2级</option>
                            <option value="3级">3级</option>
                        </select>
                    </div>

                </div>




                <div class="layui-inline" style="width:2000px">
                    <label class="layui-form-label"> 备注</label>
                    <div class="layui-input-inline layui-input-wrap">
                        <div class="layui-input-inline">
                            <textarea name="clientremark" placeholder="" id="" class="layui-textarea"></textarea>
                        </div>

                    </div>

                </div>
                <hr />
                <h3>服务人员</h3>
                <hr />
                <div class="layui-inline" style="width:2000px">
                    <label class="layui-form-label" style="width:110px"> 所属市场</label>
                    <div class="layui-input-inline">
                        <select name="city" id="marketName" lay-filter="aihao">
                            <option value="">请选择</option>
                            <option value="华南市场部">华南市场部</option>
                            <option value="华北市场部">华北市场部</option>
                            <option value="海外市场部">海外市场部</option>
                        </select>
                    </div>

                    <label class="layui-form-label" style="width:100px">业务员</label>
                    <div class="layui-input-inline">
                        <select name="city" id="salesmanName" lay-filter="aihao">
                            <option value="">请选择</option>
                            <option value="张三">张三</option>
                            <option value="李思">李思</option>
                            <option value="王五">王五</option>
                        </select>
                    </div>

                </div>



                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="submit" class="layui-btn" lay-submit lay-filter="demo1" >保存</button>
                    </div>
                </div>

            </div>
        </div>
    </form>
    <!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
    @* <script src="//unpkg.com/layui@2.9.18/dist/layui.js"></script> *@
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=rp5j6DYVV8tDQoOMrbQgAFxrAwnKvcWM"></script>
</body>
</html>


<script>
    layui.use(function () {
        var form = layui.form;
        var layer = layui.layer;

        // 提交事件
        form.on('submit(demo1)', function (d) {
            var data = {
                clientTypeName: $("[name=clientTypeName]:checked").val(),
                responsiblePhone: $("#responsiblePhone").val(),
                responsibleName: $("#responsibleName").val(),
                clientName: $("#clientName").val(),
                clientCard: $("#clientCard").val(),
                clientAddr: $("#clientAddr").val(),
                cVindustry: $("#cVindustry").val(),
                cvCreditcode: $("#cvCreditcode").val(),
                cVmnemonic: $("#cVmnemonic").val(),
                clientarchives: $("#clientarchives").val(),
                clientstage: $("#clientstage").val(),
                cVstatus: $("[name=cVstatus]:checked").val(),
                clientlabel: $("#clientlabel").val(),
                clientproducts: $("#clientproducts").val(),
                clientcooperate: $("#clientcooperate").val(),
                cvAffiliation: $("#cvAffiliation").val(),
                superiorClient: $("#superiorClient").val(),
                clientlevel: $("#clientlevel").val(),
                clientremark: $("#clientremark").val(),
                marketName: $("#marketName").val(),
                salesmanName: $("#salesmanName").val(),
            }
            $.ajax({
                url: "http://localhost:5269/api/Vendor/CreateClient",
                type: 'post',
                data: JSON.stringify(data),
                dataType: "json",
                contentType: "application/json",
                success: res => {
                    console.log(res, 555);
                    if (res.code == 0) {
                        layer.msg('添加成功')
                        // location.href = "/Birth/Death/"
                    }
                    else {
                        layer.msg('保存失败')
                    }
                }
            })
            return false; // 阻止默认 form 跳转
        });

    });


    //创建和初始化地图函数：
    function initMap() {
        createMap();//创建地图
        setMapEvent();//设置地图事件
        addMapControl();//向地图添加控件
        addMarker();//向地图中添加marker
    }

    //创建地图函数：
    function createMap() {
        var map = new BMap.Map("dituContent");//在百度地图容器中创建一个地图
        var point = new BMap.Point(116.403963, 39.915119);//定义一个中心点坐标
        map.centerAndZoom(point, 17);//设定地图的中心点和坐标并将地图显示在地图容器中
        window.map = map;//将map变量存储在全局
    }

    //地图事件设置函数：
    function setMapEvent() {
        map.enableDragging();//启用地图拖拽事件，默认启用(可不写)
        map.enableScrollWheelZoom();//启用地图滚轮放大缩小
        map.enableDoubleClickZoom();//启用鼠标双击放大，默认启用(可不写)
        map.enableKeyboard();//启用键盘上下左右键移动地图
    }

    //地图控件添加函数：
    function addMapControl() {
        //向地图中添加缩放控件
        var ctrl_nav = new BMap.NavigationControl({ anchor: BMAP_ANCHOR_TOP_LEFT, type: BMAP_NAVIGATION_CONTROL_LARGE });
        map.addControl(ctrl_nav);
        //向地图中添加缩略图控件
        var ctrl_ove = new BMap.OverviewMapControl({ anchor: BMAP_ANCHOR_BOTTOM_RIGHT, isOpen: 1 });
        map.addControl(ctrl_ove);
        //向地图中添加比例尺控件
        var ctrl_sca = new BMap.ScaleControl({ anchor: BMAP_ANCHOR_BOTTOM_LEFT });
        map.addControl(ctrl_sca);
    }

    //标注点数组
    var markerArr = [{ title: "我的标记", content: "我的备注", point: "116.403936|39.915147", isOpen: 0, icon: { w: 21, h: 21, l: 0, t: 0, x: 6, lb: 5 } }
    ];
    //创建marker
    function addMarker() {
        for (var i = 0; i < markerArr.length; i++) {
            var json = markerArr[i];
            var p0 = json.point.split("|")[0];
            var p1 = json.point.split("|")[1];
            var point = new BMap.Point(p0, p1);
            var iconImg = createIcon(json.icon);
            var marker = new BMap.Marker(point, { icon: iconImg });
            var iw = createInfoWindow(i);
            var label = new BMap.Label(json.title, { "offset": new BMap.Size(json.icon.lb - json.icon.x + 10, -20) });
            marker.setLabel(label);
            map.addOverlay(marker);
            label.setStyle({
                borderColor: "#808080",
                color: "#333",
                cursor: "pointer"
            });

            (function () {
                var index = i;
                var _iw = createInfoWindow(i);
                var _marker = marker;
                _marker.addEventListener("click", function () {
                    this.openInfoWindow(_iw);
                });
                _iw.addEventListener("open", function () {
                    _marker.getLabel().hide();
                })
                _iw.addEventListener("close", function () {
                    _marker.getLabel().show();
                })
                label.addEventListener("click", function () {
                    _marker.openInfoWindow(_iw);
                })
                if (!!json.isOpen) {
                    label.hide();
                    _marker.openInfoWindow(_iw);
                }
            })()
        }
    }
    //创建InfoWindow
    function createInfoWindow(i) {
        var json = markerArr[i];
        var iw = new BMap.InfoWindow("<b class='iw_poi_title' title='" + json.title + "'>" + json.title + "</b><div class='iw_poi_content'>" + json.content + "</div>");
        return iw;
    }
    //创建一个Icon
    function createIcon(json) {
        var icon = new BMap.Icon("http://app.baidu.com/map/images/us_mk_icon.png", new BMap.Size(json.w, json.h), { imageOffset: new BMap.Size(-json.l, -json.t), infoWindowOffset: new BMap.Size(json.lb + 5, 1), offset: new BMap.Size(json.x, json.h) })
        return icon;
    }

    initMap();//创建和初始化地图


</script>

